import json
from tencentcloud.common import credential
from tencentcloud.common.profile.client_profile import ClientProfile
from tencentcloud.common.profile.http_profile import HttpProfile
from tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKException
from tencentcloud.dnspod.v20210323 import dnspod_client, models
import get_public_ip


user_public_ip = get_public_ip.get_local_public_ip()

print(user_public_ip)


type(user_public_ip)

try:

    params = {
        "Domain": "avinfo.fun",
        "SubDomain": "v",
        "RecordType": "A",
        "RecordLine": "默认",
        "Value": str(user_public_ip,'utf-8'),
        "RecordId": 1398088451
    }

    cred = credential.Credential("AKIDkQ0JWnuiR34wwUwGmJiuIZjov0HNn8Vy", "jIoFtPHEYs69Tkx0qUw4EneXPHXZgWMM")
    httpProfile = HttpProfile()
    httpProfile.endpoint = "dnspod.tencentcloudapi.com"

    clientProfile = ClientProfile()
    clientProfile.httpProfile = httpProfile
    client = dnspod_client.DnspodClient(cred, "", clientProfile)

    req = models.ModifyRecordRequest()

    req.from_json_string(json.dumps(params))

    resp = client.ModifyRecord(req)
    print(resp.to_json_string())

except TencentCloudSDKException as err:
    print(err)
